package com.wandian.game
{
	import com.wandian.game.GameData;
	import com.wandian.game.facades.SlotFacade;
	import com.wandian.ui.controls.Alert;
	import com.wandian.utils.Debuger;
	import com.wandian.utils.Res;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import flash.utils.Timer;
	[SWF(backgroundColor="0x000000", width="982", height="736")]
	public class GameBootstrap extends Bootstrap
	{
		/**
		 * 游戏引导
		 */
		public function GameBootstrap()
		{
			super();
			Debuger.init(stage);
		}

		private var resDomain:ApplicationDomain=new ApplicationDomain(ApplicationDomain.currentDomain);

		override protected function onStart():void
		{
			var loader:Loader=new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onResLoadComplete);
			var context:LoaderContext=new LoaderContext(false, resDomain);

			loader.load(new URLRequest("res.swf"), context);

		}

		private function init():void
		{
			//var info:GameInfo=new GameInfo()
			GameData.readCache();
			var facade:SlotFacade=new SlotFacade("SlotFacade");
			facade.start();
			this.addChild(facade.getContentView());
//			Debuger.print("GameBootstrap 初始化ok");
//			Alert.init(this);
//			Alert.show("启动游戏了");
		}

		private function onResLoadComplete(e:Event):void
		{
			Res.init(resDomain);
			init();
		}

		private function onTimer(e:TimerEvent):void
		{
			//cd.setCurrent(timer.currentCount);
			//cd.update();
		}
	}
}
